<template>
	<view class="entrustList">
		<template v-for="(item,index) in entrustData">
			<view :key="index" class="items" @click.stop="toHomepage(item)">
				<view class="flex alignCenter">
					<image :src="item.foundUserAvatar"></image>
					<view class="item-info">
						<view class="name font14 bold">{{item.foundUserName}}</view>
						<view class="schoolItem font12">{{item.schoolName}} | {{item.majorName}}</view>
					</view>
				</view>
			</view>
		</template>
		<uni-nodata v-if="entrustData.length==0"></uni-nodata>
	</view>
</template>

<script>
	import { pleasePeople } from "@/api/mine.js"
	export default {
		data() {
			return {
				findId:'',
				entrustData:[],
				page:1,
				pageSize:20,
				pageTotal:0
			};
		},
		onLoad(option) {
			this.findId=option.id?option.id:''
			this.getList()
		},
		methods:{
			getList(){
				let param={
					page:this.page,
					size:this.pageSize,
					id:this.findId
				}
				pleasePeople(param).then((res)=>{
					if(res.code==100000){
						this.entrustData=this.entrustData.concat(res.data.rows)
						this.pageTotal=Math.ceil(res.data.total/this.pageSize)
					}
				})
			},
			// 去主页
			toHomepage(item){
				uni.navigateTo({
					url:'/pages/mine/homePage/homePage?userId='+item.foundUserId
				})
			}
		},
		onReachBottom() {
			if(this.page<this.pageTotal){
				++this.page
				this.getList()
			}else{
				uni.showToast({
					title:'我也是有底线的',
					icon:'none'
				})
			}
		}
	}
</script>
<style lang="scss">
page{
	background: $pageBgColor;
}
</style>
<style lang="scss" scoped>
.entrustList{
	padding: 30rpx;
	box-sizing: border-box;
}
.items{
	background: #fff;
	margin-bottom: 20rpx;
	border-radius: 30rpx;
	padding: 20rpx;
	image{
		width: 112rpx;
		height: 112rpx;
		border-radius: 50%;
		margin-right: 32rpx;
	}
	.item-info{
		width: 78%;
		.name{
			color: #333;
			line-height: 56rpx;
		}
		.schoolItem{
			color: #333;
			line-height: 1em;
		}
	}
}
</style>
